<template>
    <tpl name="MAP" src="res/tpl/map.tpl"></tpl>
    <tpl #for="monsters" #value="v" src="res/tpl/monster.tpl" :info="v"></tpl>
    <tpl name="PLAYERS" #for="players" #value="v" src="res/tpl/player.tpl" :info="v"></tpl>
    <tpl name="PLAYER" src="res/tpl/player.tpl" :info="playerInfo" self="true"></tpl>
    <tpl name="UI" src="res/tpl/ui.tpl"></tpl>
    <tpl name="TIP" src="res/tpl/tip.tpl" x="801" y="0" index="999" content=""></tpl>
    <audio src="res/audio/bg.ogg" loop="true" play="false" :speed="bgmSpeed"></audio>
    <box x="580" y="120" note="测试组件">
        <img src="res/ui/ground5.png" width="100" height="140" grid="[25,25,25,25]"></img>
        <txt text="测试" x="20" y="20" size="24" color="#ff0000"></txt>
        <tpl src="res/tpl/components/button.tpl" icon="res/ui/buttonLN.png" x="10" y="50" title="123" @click="test()"></tpl>
    </box>
</template>

<script>
init(){
    this.bgmSpeed = 1;
    this.players = [];
    this.monsters = [];
    this.playerInfo= {
		name: "凯哥",
		level: 255,
		status: 0,//0站立 1行走 2跑步 3物理 4魔法 5死亡
		dir: 4,//移动方向
		body: 3,//人物外观,主要用于区分多个资源
		mapId: 3,//地图代码
		x: 130,//地图坐标
		y: 95,//地图坐标
	};
    this.monsterInfo= {
        id: 1,
        name: "祖玛卫士",
		level: 255,
		status: 0,//0站立 1行走 2无 3物理 4无 5死亡
		dir: 4,//移动方向
		body: 1,//人物外观,主要用于区分多个资源
		mapId: 3,//地图代码
		x: 120,//地图坐标
		y: 95,//地图坐标
    };
    for (let index = 0; index < 10; index++) {
        let player = Copy(this.playerInfo);
        player.x = Random(100, 120);
        player.x = Random(90, 100);
        this.players.push(player);
    }
}

create() {
    for (let index = 0; index < 10; index++) {
        let monster = Copy(this.monsterInfo);
        monster.x = Random(100, 120);
        monster.x = Random(90, 100);
        this.monsters.push(monster);
    }
    
    console.log("game create");
}

update(delta) {

}

destroyed() {
    
}

screenMove(x, y) {
    
}

test() {
    //this.bgmSpeed = 3;
    let monster = Copy(this.monsterInfo);
    monster.x = Random(100, 120);
    monster.x = Random(90, 100);
    this.monsters.push(monster);
}

</script>